<script setup>
import Header from '@/components/Header.vue'
import { ref } from 'vue'
import request from '@/utils/request.js'
import Cookie from '@/utils/Cookie.js'
import router from '@/routers/router.js'

let username = ref('');
let password = ref('');

// 登录
function login() {
  request.instance.post('/system/login', null, {
    params: {
      'username': username.value,
      'password': password.value
    }
  }).then(res => {
    if (res===null||res==='') {
      console.log("登录失败")
    } else {
      console.log("登录成功")
      Cookie.setCookie('token', res, 4);
      router.push('/messageplus/home')
    }
  })
}
</script>
<template>
  <Header></Header>
  <form style="margin: 100px auto; width: 250px">
    <label for="name">账户：</label><input type="text" v-model="username" style="width: 200px;"><br>
    <label for="name">密码：</label><input type="password" v-model="password" style="width: 200px;">
    <input type="button" value="登录" style="margin: 10px 100px; width: 50px;" @click="login">
  </form>
</template>
<style scoped>
</style>